package cn.iocoder.yudao.module.hs.dal.mysql.receiveorderdetail;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.hs.controller.admin.receiveorderdetail.vo.ReceiveOrderDetailPageReqVO;
import cn.iocoder.yudao.module.hs.controller.admin.receiveorderdetail.vo.ReceiveOrderDetailRespVO;
import cn.iocoder.yudao.module.hs.dal.dataobject.receiveorderdetail.ReceiveOrderDetailDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 收货单明细 Mapper
 *
 * @author 航盛
 */
@Mapper
public interface ReceiveOrderDetailMapper extends BaseMapperX<ReceiveOrderDetailDO> {

    default PageResult<ReceiveOrderDetailDO> selectPage(ReceiveOrderDetailPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ReceiveOrderDetailDO>()
                .eqIfPresent(ReceiveOrderDetailDO::getOrderId, reqVO.getOrderId())
                .likeIfPresent(ReceiveOrderDetailDO::getMaterialName, reqVO.getMaterialName())
                .likeIfPresent(ReceiveOrderDetailDO::getMaterialCode, reqVO.getMaterialCode())
                .likeIfPresent(ReceiveOrderDetailDO::getModeCode, reqVO.getModeCode())
                .likeIfPresent(ReceiveOrderDetailDO::getBoxCode, reqVO.getBoxCode())
                .likeIfPresent(ReceiveOrderDetailDO::getTrayCode, reqVO.getTrayCode())
                .likeIfPresent(ReceiveOrderDetailDO::getRfidCode, reqVO.getRfidCode())
                .eqIfPresent(ReceiveOrderDetailDO::getReceiveType, reqVO.getReceiveType())
                .betweenIfPresent(ReceiveOrderDetailDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ReceiveOrderDetailDO::getId));
    }

    default List<ReceiveOrderDetailDO> selectListByShipOrderId(Long shipOrderId) {
        return selectList(new LambdaQueryWrapperX<ReceiveOrderDetailDO>()
                .eq(ReceiveOrderDetailDO::getShipOrderId, shipOrderId));
    }

    @DataPermission(enable = false)
    IPage<ReceiveOrderDetailRespVO> selectPageNotReceiveRecord(IPage<ReceiveOrderDetailRespVO> ipage, @Param("pageReqVO") ReceiveOrderDetailPageReqVO pageReqVO);

}